package pcsd.task;

import java.io.Serializable;

import pcsd.Result;
import pcsd.Task;

/**
 * This is a simple task which delays its execution for some
 * specified time.
 * 
 * @author Benjamin Ertl, Justinas Murzinas, Boyan Mihaylov
 */
public class SleepTask implements Task, Serializable {

	private static final long serialVersionUID = 81376L;
	
	/** Time (in miliseconds) to sleep */
	private int timeToSleep;
	
	public SleepTask(int timeToSleep) {
		this.timeToSleep = timeToSleep;
	}

	@Override
	public Result execute() {
		try {
			Thread.sleep(this.timeToSleep);
		} 
		catch (InterruptedException e) {
			e.printStackTrace();
		}
		return new Result(0, "Slept for " + this.timeToSleep);
	}
	
}